<template>
    <view class="page">	
		<view class="popup-view">
			<view class="yugou">
				<view class="yg-first">登录名称:</view>
				<view class="yg-second">{{userInfo.uname}}</view>
			</view>
			<view class="yugou">
				<view class="yg-first">新密码:</view>
				<view class="yg-second">
					<input v-model="password"  type="password" placeholder="请输入新密码" />
				</view>
			</view>
			<view class="yugou">
				<view class="yg-first">确认密码:</view>
				<view class="yg-second">
					<input v-model="againpword"  type="password" placeholder="请输入确认密码" />
				</view>
			</view>
		</view>
		<view class="button" @click="changePassword()">确认修改</view>
		<view class="checkvalue">{{checkvalue}}</view>
	</view>
</template>
<script>
    import {secondpassword } from '@/service/getData.js';
    import {mapMutations,mapState } from 'vuex';
	import { router, toast, check } from '@/common/util.js';
    export default {
        data() {
            return {
				oldpassword: '',
				password: '',
				againpword: '',
				checkvalue: '',
            };
        },
		computed:{
            ...mapState([ 'userInfo']),
		},
		onLoad(){
		},
        methods: {
            changePassword(){
				let str =check.password(this.password);
				if(str == ''){
				    this.checkvalue = '';
				}else{
				    this.checkvalue = str;
					return;
				}
				if(this.password != this.againpword){
					return this.checkvalue = '两次输入的密码不一致';
				}
				toast.loading();
				let sent ={"type":"userinfopass","uid":this.userInfo.uid,"realname":this.userInfo.realname,"sjh":this.userInfo.mobile,"pass":this.password};
				// console.log(JSON.stringify(sent) )
				secondpassword({data:sent}).then(res => {
					this.password= '',
					this.againpword= '',
					toast.hideLoading();
					let arr = eval('('+res.data+')');
					if(arr[0].stat == 1){
						toast.success("修改密码成功");
					}
					setTimeout(function(){
						router.navigateBack();						          
					},1200);
					});
			}
        }
    };
</script>

<style lang="scss">
	.popup-view{
		display: flex;
		flex-direction: column;
		background-color: #fff;
		.yugou{
			padding:32upx 20upx;
			display: flex;
			flex-direction: row;
			border-bottom: 1px solid #dadada;
			color: #000000;
			.yg-first{
				width: 22%;
				text-align: right;
				font-size: 30upx;
			}
			.yg-second{
				margin-left: 30upx;
				input{
					font-size: 30upx;
				}
			}
		}
	}
	.button{
		background-color: #0289ff;
		font-size: 34upx;
		border: 1upx solid #0289ff;
		border-radius: 10upx;
		margin: 50upx 50upx 10upx 50upx;
		text-align: center;
		color: #ffffff;
		padding: 20upx 0;
	}
	.checkvalue{
		color: red;
		font-size: 26upx;
		margin: 0upx 50upx 10upx 50upx;
	}
</style>
